package com.dollar.producer_consumer.orderConsume;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.Callable;

public class ProcessTask implements Callable<Boolean> {

    /**
     * 自己监控的内存队列
     */
    private ArrayBlockingQueue<String> queue;

    public ProcessTask(ArrayBlockingQueue<String> queue) {
        this.queue = queue;
    }

    @Override
    public Boolean call() throws Exception {
        try {
            while (true) {
                String request = queue.take();
                System.out.println(Thread.currentThread().getName() + " process: " + request);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return true;
    }

}